package com.cloudlead.fleetAction.action;

import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.fleetAction.BusinessModules;
import com.cloudlead.fleetAction.service.FleetCustomerSer;
import com.cloudlead.fleetService.FleetCustomerSerivce;
import com.cloudlead.fleetService.vo.BaseFleetCustomerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;

/**
 * Created by Will on 2015/12/16.
 */
@Controller
public class BaseFleetCustomerAciontFactory extends AbstractActionFactory implements FleetCustomerSerivce {
    @Autowired
    FleetCustomerSer fleetCustomerSer;
    public BaseFleetCustomerAciontFactory() {
        super(BusinessModules.FleetCustomer);
    }
    @Override
    @Action
    @Order(1)
    @Label("新增车队用户")
    public String addFleetCustomer(BaseFleetCustomerVo baseFleetCustomerVo) {
        return  fleetCustomerSer.addFleetCustomer(baseFleetCustomerVo);
    }

    @Override
    @Action
    @Order(2)
    @Label("删除车队用户")
    public String delFleetCustomer(@NotNull @Label("车队客户ID")String fleetCustomerId) {
        return fleetCustomerSer.delFleetCustomer(fleetCustomerId);
    }
    @Override
    @Action
    @Order(3)
    @Label("编辑车队用户")
    public String editFleetCustomer(BaseFleetCustomerVo baseFleetCustomerVo) {
        return fleetCustomerSer.editFleetCustomer(baseFleetCustomerVo);
    }

    @Override
    @Action
    @Order(4)
    @Label("查询车队用户")
    public EasyuiGridData findAll(BaseFleetCustomerVo baseFleetCustomerVo, @NotNull @Label("每页记录条数")int rows, @NotNull @Label("页码")int page) {
        return new EasyuiGridData(fleetCustomerSer.findAll(baseFleetCustomerVo,rows,page),"id,companyName,companyShortName,state," +
                "companyAddress,companyContact,companyPhone1,companyFax,accountName,accountNumber,companyType,province," +
                "city,qq,email,phone,comments,carsCount,accountNumber,bank,baseCompany.id baseCompanyId");
    }

    @Override
    @Action
    @Order(5)
    @Label("恢复车队客户")
    public void hfFleetCustomer(String id) {
        fleetCustomerSer.hfBaseDriver(id);
    }
}
